package io.zhengsh.vvip.leetcode.divideandconquer;

public class Q50 {


    class Solution {

        double myPow(double x, long n) {
            long N = n;
            return N >= 0 ? quickMul(x, N) : 1.0 / quickMul(x, -N);
        }

        public double quickMul(double x, long N) {
            if (N == 0 || x == 1) {
                return 1.0;
            }
            double y = quickMul(x, N / 2);
            return N % 2 == 0 ? y * y : y * y * x;
        }
    }
}
